﻿@{
    ViewBag.Title = "ExchangeGift";
}
@using MMS.UI.Extension;
@section headSection{
     
<script src="/Scripts/echarts.js"></script>
    @*礼品兑换数据表格*@
    <script type="text/javascript">
        $(function () {
            $.globalHelper.datagridPara.init("/Admin/MembershipAnalysis/ExchangeGift",
                [@Html.GetSonBtnJs()],
                [[
                { field: 'Gname', title: '商品名称', width: 50 },
                { field: 'Count', title: '总兑换数量', width: 50, sortable: true },
                
                ]]);

            $("#tbList").datagrid($.globalHelper.datagridPara.paras);
        });
    </script>
    @*礼品兑换数据分析图*@
     <script type="text/javascript">
         $.post('/Admin/MembershipAnalysis/ExchangeGift', function (jsonText) {
             var myChart = echarts.init(document.getElementById('main'), 'macarons');
             myChart.setOption({
                 title: {
                     text: '礼品兑换分析图',
                     subtext: '本数据真实有效',
                     x: 'center'
                 },
                 tooltip: {
                     trigger: 'item',
                     formatter: "{b}<br/>总数:{c},占({d}%)"
                 },
                 legend: {
                     orient: 'vertical',
                     left: 'left',
                     data: []
                 },
                 series: [
                     {
                         name: '兑换的商品',
                         type: 'pie',
                         radius: '55%',
                         center: ['50%', '60%'],
                         data: [],
                         itemStyle: {
                             emphasis: {
                                 shadowBlur: 10,
                                 shadowOffsetX: 0,
                                 shadowColor: 'rgba(0, 0, 0, 0.5)'
                             }
                         }
                     }]
             });
             myChart.showLoading();
             var dataName = [];
             var dataCount = [];
             if (typeof (jsonText) == "string") {
                 try {
                     jsonText = eval(jsonText);
                 } catch (e) {
                     try {
                         jsonText = eval("(" + jsonText + ")");
                     } catch (e) {
                         aler("格式错误：必须为json格式字符串！");
                     }

                 }

             }
             for (var i = 0; i < jsonText.length; i++) {
                 dataName[i] = jsonText[i].Gname;
                 dataCount[i] = { value: jsonText[i].Count, name: jsonText[i].Gname };

             }
             myChart.hideLoading();
             myChart.setOption({
                 legend: {
                     data: dataName
                 },
                 series: [{
                     data: dataCount
                 }]
             })

         });
     </script>
     }

<table id="tbList"></table>
<div id="main" style="width: 100%;height:400px;"></div>
